1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.DBusProxy; 26 27 private import gio.AsyncInitableIF; 28 private import gio.AsyncInitableT; 29 private import gio.AsyncResultIF; 30 private import gio.Cancellable; 31 private import gio.DBusConnection; 32 private import gio.DBusInterfaceIF; 33 private import gio.DBusInterfaceInfo; 34 private import gio.DBusInterfaceT; 35 private import gio.InitableIF; 36 private import gio.InitableT; 37 private import gio.UnixFDList; 38 private import gio.c.functions; 39 public import gio.c.types; 40 private import glib.ConstructionException; 41 private import glib.ErrorG; 42 private import glib.GException; 43 private import glib.Str; 44 private import glib.Variant; 45 private import glib.c.functions; 46 private import gobject.ObjectG; 47 private import gobject.Signals; 48 private import std.algorithm; 49 50 51 /** 52 * #GDBusProxy is a base class used for proxies to access a D-Bus 53 * interface on a remote object. A #GDBusProxy can be constructed for 54 * both well-known and unique names. 55 * 56 * By default, #GDBusProxy will cache all properties (and listen to 57 * changes) of the remote object, and proxy all signals that get 58 * emitted. This behaviour can be changed by passing suitable 59 * #GDBusProxyFlags when the proxy is created. If the proxy is for a 60 * well-known name, the property cache is flushed when the name owner 61 * vanishes and reloaded when a name owner appears. 62 * 63 * The unique name owner of the proxy's name is tracked and can be read from 64 * #GDBusProxy:g-name-owner. Connect to the #GObject::notify signal to 65 * get notified of changes. Additionally, only signals and property 66 * changes emitted from the current name owner are considered and 67 * calls are always sent to the current name owner. This avoids a 68 * number of race conditions when the name is lost by one owner and 69 * claimed by another. However, if no name owner currently exists, 70 * then calls will be sent to the well-known name which may result in 71 * the message bus launching an owner (unless 72 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set). 73 * 74 * If the proxy is for a stateless D-Bus service, where the name owner may 75 * be started and stopped between calls, the #GDBusProxy:g-name-owner tracking 76 * of #GDBusProxy will cause the proxy to drop signal and property changes from 77 * the service after it has restarted for the first time. When interacting 78 * with a stateless D-Bus service, do not use #GDBusProxy — use direct D-Bus 79 * method calls and signal connections. 80 * 81 * The generic #GDBusProxy::g-properties-changed and 82 * #GDBusProxy::g-signal signals are not very convenient to work with. 83 * Therefore, the recommended way of working with proxies is to subclass 84 * #GDBusProxy, and have more natural properties and signals in your derived 85 * class. This [example][gdbus-example-gdbus-codegen] shows how this can 86 * easily be done using the [gdbus-codegen][gdbus-codegen] tool. 87 * 88 * A #GDBusProxy instance can be used from multiple threads but note 89 * that all signals (e.g. #GDBusProxy::g-signal, #GDBusProxy::g-properties-changed 90 * and #GObject::notify) are emitted in the 91 * [thread-default main context][g-main-context-push-thread-default] 92 * of the thread where the instance was constructed. 93 * 94 * An example using a proxy for a well-known name can be found in 95 * [gdbus-example-watch-proxy.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gdbus-example-watch-proxy.c) 96 * 97 * Since: 2.26 98 */ 99 public class DBusProxy : ObjectG, AsyncInitableIF, DBusInterfaceIF, InitableIF 100 { 101 /** the main Gtk struct */ 102 protected GDBusProxy* gDBusProxy; 103 104 /** Get the main Gtk struct */ 105 public GDBusProxy* getDBusProxyStruct(bool transferOwnership = false) 106 { 107 if (transferOwnership) 108 ownedRef = false; 109 return gDBusProxy; 110 } 111 112 /** the main Gtk struct as a void* */ 113 protected override void* getStruct() 114 { 115 return cast(void*)gDBusProxy; 116 } 117 118 /** 119 * Sets our main struct and passes it to the parent class. 120 */ 121 public this (GDBusProxy* gDBusProxy, bool ownedRef = false) 122 { 123 this.gDBusProxy = gDBusProxy; 124 super(cast(GObject*)gDBusProxy, ownedRef); 125 } 126 127 // add the AsyncInitable capabilities 128 mixin AsyncInitableT!(GDBusProxy); 129 130 // add the DBusInterface capabilities 131 mixin DBusInterfaceT!(GDBusProxy); 132 133 // add the Initable capabilities 134 mixin InitableT!(GDBusProxy); 135 136 /** 137 * Finishes creating a GDBusProxy. 138 * 139 * Params: 140 * res = A GAsyncResult obtained from the GAsyncReadyCallback 141 * function passed to g_dbus_proxy_new(). 142 * forBus = If true finish an address. 143 * 144 * Throws: GException on failure. 145 * Throws: ConstructionException GTK+ fails to create the object. 146 * 147 * Since: 2.26 148 */ 149 public this (AsyncResultIF res, bool forBus = false) 150 { 151 GError* err = null; 152 GDBusProxy* p; 153 154 if ( forBus ) 155 { 156 p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 157 } 158 else 159 { 160 p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); 161 } 162 163 if (err !is null) 164 { 165 throw new GException( new ErrorG(err) ); 166 } 167 168 if(p is null) 169 { 170 throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); 171 } 172 this(p, true); 173 } 174 175 /** 176 */ 177 178 /** */ 179 public static GType getType() 180 { 181 return g_dbus_proxy_get_type(); 182 } 183 184 /** 185 * Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. 186 * 187 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 188 * 189 * Params: 190 * busType = A #GBusType. 191 * flags = Flags used when constructing the proxy. 192 * info = A #GDBusInterfaceInfo specifying the minimal interface 193 * that @proxy conforms to or %NULL. 194 * name = A bus name (well-known or unique). 195 * objectPath = An object path. 196 * interfaceName = A D-Bus interface name. 197 * cancellable = A #GCancellable or %NULL. 198 * 199 * Returns: A #GDBusProxy or %NULL if error is set. 200 * Free with g_object_unref(). 201 * 202 * Since: 2.26 203 * 204 * Throws: GException on failure. 205 * Throws: ConstructionException GTK+ fails to create the object. 206 */ 207 public this(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable) 208 { 209 GError* err = null; 210 211 auto __p = g_dbus_proxy_new_for_bus_sync(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 212 213 if (err !is null) 214 { 215 throw new GException( new ErrorG(err) ); 216 } 217 218 if(__p is null) 219 { 220 throw new ConstructionException("null returned by new_for_bus_sync"); 221 } 222 223 this(cast(GDBusProxy*) __p, true); 224 } 225 226 /** 227 * Creates a proxy for accessing @interface_name on the remote object 228 * at @object_path owned by @name at @connection and synchronously 229 * loads D-Bus properties unless the 230 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. 231 * 232 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 233 * match rules for signals. Connect to the #GDBusProxy::g-signal signal 234 * to handle signals from the remote object. 235 * 236 * If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and 237 * %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is 238 * guaranteed to return immediately without blocking. 239 * 240 * If @name is a well-known name and the 241 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION 242 * flags aren't set and no name owner currently exists, the message bus 243 * will be requested to launch a name owner for the name. 244 * 245 * This is a synchronous failable constructor. See g_dbus_proxy_new() 246 * and g_dbus_proxy_new_finish() for the asynchronous version. 247 * 248 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 249 * 250 * Params: 251 * connection = A #GDBusConnection. 252 * flags = Flags used when constructing the proxy. 253 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 254 * name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 255 * objectPath = An object path. 256 * interfaceName = A D-Bus interface name. 257 * cancellable = A #GCancellable or %NULL. 258 * 259 * Returns: A #GDBusProxy or %NULL if error is set. 260 * Free with g_object_unref(). 261 * 262 * Since: 2.26 263 * 264 * Throws: GException on failure. 265 * Throws: ConstructionException GTK+ fails to create the object. 266 */ 267 public this(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable) 268 { 269 GError* err = null; 270 271 auto __p = g_dbus_proxy_new_sync((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 272 273 if (err !is null) 274 { 275 throw new GException( new ErrorG(err) ); 276 } 277 278 if(__p is null) 279 { 280 throw new ConstructionException("null returned by new_sync"); 281 } 282 283 this(cast(GDBusProxy*) __p, true); 284 } 285 286 /** 287 * Creates a proxy for accessing @interface_name on the remote object 288 * at @object_path owned by @name at @connection and asynchronously 289 * loads D-Bus properties unless the 290 * %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used. Connect to 291 * the #GDBusProxy::g-properties-changed signal to get notified about 292 * property changes. 293 * 294 * If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up 295 * match rules for signals. Connect to the #GDBusProxy::g-signal signal 296 * to handle signals from the remote object. 297 * 298 * If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and 299 * %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is 300 * guaranteed to complete immediately without blocking. 301 * 302 * If @name is a well-known name and the 303 * %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION 304 * flags aren't set and no name owner currently exists, the message bus 305 * will be requested to launch a name owner for the name. 306 * 307 * This is a failable asynchronous constructor - when the proxy is 308 * ready, @callback will be invoked and you can use 309 * g_dbus_proxy_new_finish() to get the result. 310 * 311 * See g_dbus_proxy_new_sync() and for a synchronous version of this constructor. 312 * 313 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 314 * 315 * Params: 316 * connection = A #GDBusConnection. 317 * flags = Flags used when constructing the proxy. 318 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 319 * name = A bus name (well-known or unique) or %NULL if @connection is not a message bus connection. 320 * objectPath = An object path. 321 * interfaceName = A D-Bus interface name. 322 * cancellable = A #GCancellable or %NULL. 323 * callback = Callback function to invoke when the proxy is ready. 324 * userData = User data to pass to @callback. 325 * 326 * Since: 2.26 327 */ 328 public static void new_(DBusConnection connection, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 329 { 330 g_dbus_proxy_new((connection is null) ? null : connection.getDBusConnectionStruct(), flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 331 } 332 333 /** 334 * Like g_dbus_proxy_new() but takes a #GBusType instead of a #GDBusConnection. 335 * 336 * #GDBusProxy is used in this [example][gdbus-wellknown-proxy]. 337 * 338 * Params: 339 * busType = A #GBusType. 340 * flags = Flags used when constructing the proxy. 341 * info = A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL. 342 * name = A bus name (well-known or unique). 343 * objectPath = An object path. 344 * interfaceName = A D-Bus interface name. 345 * cancellable = A #GCancellable or %NULL. 346 * callback = Callback function to invoke when the proxy is ready. 347 * userData = User data to pass to @callback. 348 * 349 * Since: 2.26 350 */ 351 public static void newForBus(GBusType busType, GDBusProxyFlags flags, DBusInterfaceInfo info, string name, string objectPath, string interfaceName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 352 { 353 g_dbus_proxy_new_for_bus(busType, flags, (info is null) ? null : info.getDBusInterfaceInfoStruct(), Str.toStringz(name), Str.toStringz(objectPath), Str.toStringz(interfaceName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 354 } 355 356 /** 357 * Asynchronously invokes the @method_name method on @proxy. 358 * 359 * If @method_name contains any dots, then @name is split into interface and 360 * method name parts. This allows using @proxy for invoking methods on 361 * other interfaces. 362 * 363 * If the #GDBusConnection associated with @proxy is closed then 364 * the operation will fail with %G_IO_ERROR_CLOSED. If 365 * @cancellable is canceled, the operation will fail with 366 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not 367 * compatible with the D-Bus protocol, the operation fails with 368 * %G_IO_ERROR_INVALID_ARGUMENT. 369 * 370 * If the @parameters #GVariant is floating, it is consumed. This allows 371 * convenient 'inline' use of g_variant_new(), e.g.: 372 * |[<!-- language="C" --> 373 * g_dbus_proxy_call (proxy, 374 * "TwoStrings", 375 * g_variant_new ("(ss)", 376 * "Thing One", 377 * "Thing Two"), 378 * G_DBUS_CALL_FLAGS_NONE, 379 * -1, 380 * NULL, 381 * (GAsyncReadyCallback) two_strings_done, 382 * &data); 383 * ]| 384 * 385 * If @proxy has an expected interface (see 386 * #GDBusProxy:g-interface-info) and @method_name is referenced by it, 387 * then the return value is checked against the return type. 388 * 389 * This is an asynchronous method. When the operation is finished, 390 * @callback will be invoked in the 391 * [thread-default main context][g-main-context-push-thread-default] 392 * of the thread you are calling this method from. 393 * You can then call g_dbus_proxy_call_finish() to get the result of 394 * the operation. See g_dbus_proxy_call_sync() for the synchronous 395 * version of this method. 396 * 397 * If @callback is %NULL then the D-Bus method call message will be sent with 398 * the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. 399 * 400 * Params: 401 * methodName = Name of method to invoke. 402 * parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters. 403 * flags = Flags from the #GDBusCallFlags enumeration. 404 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 405 * "infinite") or -1 to use the proxy default timeout. 406 * cancellable = A #GCancellable or %NULL. 407 * callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't 408 * care about the result of the method invocation. 409 * userData = The data to pass to @callback. 410 * 411 * Since: 2.26 412 */ 413 public void call(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 414 { 415 g_dbus_proxy_call(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 416 } 417 418 /** 419 * Finishes an operation started with g_dbus_proxy_call(). 420 * 421 * Params: 422 * res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call(). 423 * 424 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 425 * return values. Free with g_variant_unref(). 426 * 427 * Since: 2.26 428 * 429 * Throws: GException on failure. 430 */ 431 public Variant callFinish(AsyncResultIF res) 432 { 433 GError* err = null; 434 435 auto __p = g_dbus_proxy_call_finish(gDBusProxy, (res is null) ? null : res.getAsyncResultStruct(), &err); 436 437 if (err !is null) 438 { 439 throw new GException( new ErrorG(err) ); 440 } 441 442 if(__p is null) 443 { 444 return null; 445 } 446 447 return new Variant(cast(GVariant*) __p, true); 448 } 449 450 /** 451 * Synchronously invokes the @method_name method on @proxy. 452 * 453 * If @method_name contains any dots, then @name is split into interface and 454 * method name parts. This allows using @proxy for invoking methods on 455 * other interfaces. 456 * 457 * If the #GDBusConnection associated with @proxy is disconnected then 458 * the operation will fail with %G_IO_ERROR_CLOSED. If 459 * @cancellable is canceled, the operation will fail with 460 * %G_IO_ERROR_CANCELLED. If @parameters contains a value not 461 * compatible with the D-Bus protocol, the operation fails with 462 * %G_IO_ERROR_INVALID_ARGUMENT. 463 * 464 * If the @parameters #GVariant is floating, it is consumed. This allows 465 * convenient 'inline' use of g_variant_new(), e.g.: 466 * |[<!-- language="C" --> 467 * g_dbus_proxy_call_sync (proxy, 468 * "TwoStrings", 469 * g_variant_new ("(ss)", 470 * "Thing One", 471 * "Thing Two"), 472 * G_DBUS_CALL_FLAGS_NONE, 473 * -1, 474 * NULL, 475 * &error); 476 * ]| 477 * 478 * The calling thread is blocked until a reply is received. See 479 * g_dbus_proxy_call() for the asynchronous version of this 480 * method. 481 * 482 * If @proxy has an expected interface (see 483 * #GDBusProxy:g-interface-info) and @method_name is referenced by it, 484 * then the return value is checked against the return type. 485 * 486 * Params: 487 * methodName = Name of method to invoke. 488 * parameters = A #GVariant tuple with parameters for the signal 489 * or %NULL if not passing parameters. 490 * flags = Flags from the #GDBusCallFlags enumeration. 491 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 492 * "infinite") or -1 to use the proxy default timeout. 493 * cancellable = A #GCancellable or %NULL. 494 * 495 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 496 * return values. Free with g_variant_unref(). 497 * 498 * Since: 2.26 499 * 500 * Throws: GException on failure. 501 */ 502 public Variant callSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, Cancellable cancellable) 503 { 504 GError* err = null; 505 506 auto __p = g_dbus_proxy_call_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 507 508 if (err !is null) 509 { 510 throw new GException( new ErrorG(err) ); 511 } 512 513 if(__p is null) 514 { 515 return null; 516 } 517 518 return new Variant(cast(GVariant*) __p, true); 519 } 520 521 /** 522 * Like g_dbus_proxy_call() but also takes a #GUnixFDList object. 523 * 524 * This method is only available on UNIX. 525 * 526 * Params: 527 * methodName = Name of method to invoke. 528 * parameters = A #GVariant tuple with parameters for the signal or %NULL if not passing parameters. 529 * flags = Flags from the #GDBusCallFlags enumeration. 530 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 531 * "infinite") or -1 to use the proxy default timeout. 532 * fdList = A #GUnixFDList or %NULL. 533 * cancellable = A #GCancellable or %NULL. 534 * callback = A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't 535 * care about the result of the method invocation. 536 * userData = The data to pass to @callback. 537 * 538 * Since: 2.30 539 */ 540 public void callWithUnixFdList(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 541 { 542 g_dbus_proxy_call_with_unix_fd_list(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 543 } 544 545 /** 546 * Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list(). 547 * 548 * Params: 549 * outFdList = Return location for a #GUnixFDList or %NULL. 550 * res = A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call_with_unix_fd_list(). 551 * 552 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 553 * return values. Free with g_variant_unref(). 554 * 555 * Since: 2.30 556 * 557 * Throws: GException on failure. 558 */ 559 public Variant callWithUnixFdListFinish(out UnixFDList outFdList, AsyncResultIF res) 560 { 561 GUnixFDList* outoutFdList = null; 562 GError* err = null; 563 564 auto __p = g_dbus_proxy_call_with_unix_fd_list_finish(gDBusProxy, &outoutFdList, (res is null) ? null : res.getAsyncResultStruct(), &err); 565 566 if (err !is null) 567 { 568 throw new GException( new ErrorG(err) ); 569 } 570 571 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 572 573 if(__p is null) 574 { 575 return null; 576 } 577 578 return new Variant(cast(GVariant*) __p, true); 579 } 580 581 /** 582 * Like g_dbus_proxy_call_sync() but also takes and returns #GUnixFDList objects. 583 * 584 * This method is only available on UNIX. 585 * 586 * Params: 587 * methodName = Name of method to invoke. 588 * parameters = A #GVariant tuple with parameters for the signal 589 * or %NULL if not passing parameters. 590 * flags = Flags from the #GDBusCallFlags enumeration. 591 * timeoutMsec = The timeout in milliseconds (with %G_MAXINT meaning 592 * "infinite") or -1 to use the proxy default timeout. 593 * fdList = A #GUnixFDList or %NULL. 594 * outFdList = Return location for a #GUnixFDList or %NULL. 595 * cancellable = A #GCancellable or %NULL. 596 * 597 * Returns: %NULL if @error is set. Otherwise a #GVariant tuple with 598 * return values. Free with g_variant_unref(). 599 * 600 * Since: 2.30 601 * 602 * Throws: GException on failure. 603 */ 604 public Variant callWithUnixFdListSync(string methodName, Variant parameters, GDBusCallFlags flags, int timeoutMsec, UnixFDList fdList, out UnixFDList outFdList, Cancellable cancellable) 605 { 606 GUnixFDList* outoutFdList = null; 607 GError* err = null; 608 609 auto __p = g_dbus_proxy_call_with_unix_fd_list_sync(gDBusProxy, Str.toStringz(methodName), (parameters is null) ? null : parameters.getVariantStruct(), flags, timeoutMsec, (fdList is null) ? null : fdList.getUnixFDListStruct(), &outoutFdList, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 610 611 if (err !is null) 612 { 613 throw new GException( new ErrorG(err) ); 614 } 615 616 outFdList = ObjectG.getDObject!(UnixFDList)(outoutFdList); 617 618 if(__p is null) 619 { 620 return null; 621 } 622 623 return new Variant(cast(GVariant*) __p, true); 624 } 625 626 /** 627 * Looks up the value for a property from the cache. This call does no 628 * blocking IO. 629 * 630 * If @proxy has an expected interface (see 631 * #GDBusProxy:g-interface-info) and @property_name is referenced by 632 * it, then @value is checked against the type of the property. 633 * 634 * Params: 635 * propertyName = Property name. 636 * 637 * Returns: A reference to the #GVariant instance 638 * that holds the value for @property_name or %NULL if the value is not in 639 * the cache. The returned reference must be freed with g_variant_unref(). 640 * 641 * Since: 2.26 642 */ 643 public Variant getCachedProperty(string propertyName) 644 { 645 auto __p = g_dbus_proxy_get_cached_property(gDBusProxy, Str.toStringz(propertyName)); 646 647 if(__p is null) 648 { 649 return null; 650 } 651 652 return new Variant(cast(GVariant*) __p, true); 653 } 654 655 /** 656 * Gets the names of all cached properties on @proxy. 657 * 658 * Returns: A 659 * %NULL-terminated array of strings or %NULL if 660 * @proxy has no cached properties. Free the returned array with 661 * g_strfreev(). 662 * 663 * Since: 2.26 664 */ 665 public string[] getCachedPropertyNames() 666 { 667 auto retStr = g_dbus_proxy_get_cached_property_names(gDBusProxy); 668 669 scope(exit) Str.freeStringArray(retStr); 670 return Str.toStringArray(retStr); 671 } 672 673 /** 674 * Gets the connection @proxy is for. 675 * 676 * Returns: A #GDBusConnection owned by @proxy. Do not free. 677 * 678 * Since: 2.26 679 */ 680 public DBusConnection getConnection() 681 { 682 auto __p = g_dbus_proxy_get_connection(gDBusProxy); 683 684 if(__p is null) 685 { 686 return null; 687 } 688 689 return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) __p); 690 } 691 692 /** 693 * Gets the timeout to use if -1 (specifying default timeout) is 694 * passed as @timeout_msec in the g_dbus_proxy_call() and 695 * g_dbus_proxy_call_sync() functions. 696 * 697 * See the #GDBusProxy:g-default-timeout property for more details. 698 * 699 * Returns: Timeout to use for @proxy. 700 * 701 * Since: 2.26 702 */ 703 public int getDefaultTimeout() 704 { 705 return g_dbus_proxy_get_default_timeout(gDBusProxy); 706 } 707 708 /** 709 * Gets the flags that @proxy was constructed with. 710 * 711 * Returns: Flags from the #GDBusProxyFlags enumeration. 712 * 713 * Since: 2.26 714 */ 715 public GDBusProxyFlags getFlags() 716 { 717 return g_dbus_proxy_get_flags(gDBusProxy); 718 } 719 720 /** 721 * Returns the #GDBusInterfaceInfo, if any, specifying the interface 722 * that @proxy conforms to. See the #GDBusProxy:g-interface-info 723 * property for more details. 724 * 725 * Returns: A #GDBusInterfaceInfo or %NULL. 726 * Do not unref the returned object, it is owned by @proxy. 727 * 728 * Since: 2.26 729 */ 730 public DBusInterfaceInfo getInterfaceInfo() 731 { 732 auto __p = g_dbus_proxy_get_interface_info(gDBusProxy); 733 734 if(__p is null) 735 { 736 return null; 737 } 738 739 return ObjectG.getDObject!(DBusInterfaceInfo)(cast(GDBusInterfaceInfo*) __p); 740 } 741 742 /** 743 * Gets the D-Bus interface name @proxy is for. 744 * 745 * Returns: A string owned by @proxy. Do not free. 746 * 747 * Since: 2.26 748 */ 749 public string getInterfaceName() 750 { 751 return Str.toString(g_dbus_proxy_get_interface_name(gDBusProxy)); 752 } 753 754 /** 755 * Gets the name that @proxy was constructed for. 756 * 757 * When connected to a message bus, this will usually be non-%NULL. 758 * However, it may be %NULL for a proxy that communicates using a peer-to-peer 759 * pattern. 760 * 761 * Returns: A string owned by @proxy. Do not free. 762 * 763 * Since: 2.26 764 */ 765 public string getName() 766 { 767 return Str.toString(g_dbus_proxy_get_name(gDBusProxy)); 768 } 769 770 /** 771 * The unique name that owns the name that @proxy is for or %NULL if 772 * no-one currently owns that name. You may connect to the 773 * #GObject::notify signal to track changes to the 774 * #GDBusProxy:g-name-owner property. 775 * 776 * Returns: The name owner or %NULL if no name 777 * owner exists. Free with g_free(). 778 * 779 * Since: 2.26 780 */ 781 public string getNameOwner() 782 { 783 auto retStr = g_dbus_proxy_get_name_owner(gDBusProxy); 784 785 scope(exit) Str.freeString(retStr); 786 return Str.toString(retStr); 787 } 788 789 /** 790 * Gets the object path @proxy is for. 791 * 792 * Returns: A string owned by @proxy. Do not free. 793 * 794 * Since: 2.26 795 */ 796 public string getObjectPath() 797 { 798 return Str.toString(g_dbus_proxy_get_object_path(gDBusProxy)); 799 } 800 801 /** 802 * If @value is not %NULL, sets the cached value for the property with 803 * name @property_name to the value in @value. 804 * 805 * If @value is %NULL, then the cached value is removed from the 806 * property cache. 807 * 808 * If @proxy has an expected interface (see 809 * #GDBusProxy:g-interface-info) and @property_name is referenced by 810 * it, then @value is checked against the type of the property. 811 * 812 * If the @value #GVariant is floating, it is consumed. This allows 813 * convenient 'inline' use of g_variant_new(), e.g. 814 * |[<!-- language="C" --> 815 * g_dbus_proxy_set_cached_property (proxy, 816 * "SomeProperty", 817 * g_variant_new ("(si)", 818 * "A String", 819 * 42)); 820 * ]| 821 * 822 * Normally you will not need to use this method since @proxy 823 * is tracking changes using the 824 * `org.freedesktop.DBus.Properties.PropertiesChanged` 825 * D-Bus signal. However, for performance reasons an object may 826 * decide to not use this signal for some properties and instead 827 * use a proprietary out-of-band mechanism to transmit changes. 828 * 829 * As a concrete example, consider an object with a property 830 * `ChatroomParticipants` which is an array of strings. Instead of 831 * transmitting the same (long) array every time the property changes, 832 * it is more efficient to only transmit the delta using e.g. signals 833 * `ChatroomParticipantJoined(String name)` and 834 * `ChatroomParticipantParted(String name)`. 835 * 836 * Params: 837 * propertyName = Property name. 838 * value = Value for the property or %NULL to remove it from the cache. 839 * 840 * Since: 2.26 841 */ 842 public void setCachedProperty(string propertyName, Variant value) 843 { 844 g_dbus_proxy_set_cached_property(gDBusProxy, Str.toStringz(propertyName), (value is null) ? null : value.getVariantStruct()); 845 } 846 847 /** 848 * Sets the timeout to use if -1 (specifying default timeout) is 849 * passed as @timeout_msec in the g_dbus_proxy_call() and 850 * g_dbus_proxy_call_sync() functions. 851 * 852 * See the #GDBusProxy:g-default-timeout property for more details. 853 * 854 * Params: 855 * timeoutMsec = Timeout in milliseconds. 856 * 857 * Since: 2.26 858 */ 859 public void setDefaultTimeout(int timeoutMsec) 860 { 861 g_dbus_proxy_set_default_timeout(gDBusProxy, timeoutMsec); 862 } 863 864 /** 865 * Ensure that interactions with @proxy conform to the given 866 * interface. See the #GDBusProxy:g-interface-info property for more 867 * details. 868 * 869 * Params: 870 * info = Minimum interface this proxy conforms to 871 * or %NULL to unset. 872 * 873 * Since: 2.26 874 */ 875 public void setInterfaceInfo(DBusInterfaceInfo info) 876 { 877 g_dbus_proxy_set_interface_info(gDBusProxy, (info is null) ? null : info.getDBusInterfaceInfoStruct()); 878 } 879 880 /** 881 * Emitted when one or more D-Bus properties on @proxy changes. The 882 * local cache has already been updated when this signal fires. Note 883 * that both @changed_properties and @invalidated_properties are 884 * guaranteed to never be %NULL (either may be empty though). 885 * 886 * If the proxy has the flag 887 * %G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES set, then 888 * @invalidated_properties will always be empty. 889 * 890 * This signal corresponds to the 891 * `PropertiesChanged` D-Bus signal on the 892 * `org.freedesktop.DBus.Properties` interface. 893 * 894 * Params: 895 * changedProperties = A #GVariant containing the properties that changed (type: `a{sv}`) 896 * invalidatedProperties = A %NULL terminated array of properties that was invalidated 897 * 898 * Since: 2.26 899 */ 900 gulong addOnGPropertiesChanged(void delegate(Variant, string[], DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 901 { 902 return Signals.connect(this, "g-properties-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 903 } 904 905 /** 906 * Emitted when a signal from the remote object and interface that @proxy is for, has been received. 907 * 908 * Since 2.72 this signal supports detailed connections. You can connect to 909 * the detailed signal `g-signal::x` in order to receive callbacks only when 910 * signal `x` is received from the remote object. 911 * 912 * Params: 913 * senderName = The sender of the signal or %NULL if the connection is not a bus connection. 914 * signalName = The name of the signal. 915 * parameters = A #GVariant tuple with parameters for the signal. 916 * 917 * Since: 2.26 918 */ 919 gulong addOnGSignal(void delegate(string, string, Variant, DBusProxy) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 920 { 921 return Signals.connect(this, "g-signal", dlg, connectFlags ^ ConnectFlags.SWAPPED); 922 } 923 }